﻿using Apps.Models.CONTRACT;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Apps.DAL.CONTRACT
{
    public partial class CONTRACT_QUALITY_DETAILRepository
    {
        public IQueryable<CONTRACT_QUALITY_DETAILModel> QueryQualityDetailList(string IndexType,string QUALITY_ID)
        {
            IQueryable<CONTRACT_QUALITY_DETAILModel> list = from a in Context.PUB_LMS_INDEX
                                                            join e in Context.CONTRACT_QUALITY_DETAIL on new { INDEXID = a.INDEX_ID, QUALITYID = QUALITY_ID } equals new { INDEXID= e.INDEX_ID , QUALITYID =e.QUALITY_ID} into mine
                                                            from te in mine.DefaultIfEmpty()
                                                            where a.INDEX_TYPE == IndexType 
                                                            select new CONTRACT_QUALITY_DETAILModel()
                                                            {
                                                                BEGIN_VALUE = te.BEGIN_VALUE,
                                                                END_VALUE = te.END_VALUE,
                                                                INDEX_CODE = a.INDEX_CODE,
                                                                INDEX_DISNAME = a.INDEX_DISNAME,
                                                                INDEX_ID = a.INDEX_ID,
                                                                INDEX_NAME = a.INDEX_NAME,
                                                                INDEX_UNIT = a.INDEX_UNIT,
                                                                QUALITY_DETAIL_ID = te.QUALITY_DETAIL_ID,
                                                                QUALITY_ID = te.QUALITY_ID
                                                            };
            return list;
        }
    }
}
